#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int kMaxN = 4e5 + 10;
const long long kInf = 1e18;

struct Edge {
  int to, no, w;
};

vector<Edge> g[kMaxN];
long long dist[kMaxN];
bool vis[kMaxN];

void Dijkstra(int n) {
  priority_queue<pair<long long, int>> pq;

  fill(dist, dist + n + 1, kInf);
  dist[1] = 0;
  pq.emplace(-dist[1], 1);
  while (!pq.empty()) {
    long long d = -pq.top().first;
    int u = pq.top().second;

    pq.pop();
    if (dist[u] != d) {
      continue;
    }
    for (const Edge &e : g[u]) {
      if (dist[e.to] > d + e.w) {
        dist[e.to] = d + e.w;
        pq.emplace(-dist[e.to], e.to);
      }
    }
  }
}

void DFS(int now, int &k) {
  vis[now] = true;
  for (const Edge &e : g[now]) {
    if (!vis[e.to] && dist[e.to] == dist[now] + e.w && k > 0) {
      cout << e.no << " ";
      k--;
      DFS(e.to, k);
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  k = min(k, n - 1);
  for (int i = 1; i <= m; i++) {
    int u, v, w;

    cin >> u >> v >> w;
    g[u].emplace_back(Edge{v, i, w});
    g[v].emplace_back(Edge{u, i, w});
  }
  Dijkstra(n);
  cout << k << "\n";
  DFS(1, k);
  cout << "\n";
  return 0;
}